package thread;


import java.util.Arrays;

public class Student implements Comparable<Student> {
    private  int stuId;
    private String stuName;
    private int score;

    public Student(int stuId, String stuName, int score) {
        this.stuId = stuId;
        this.stuName = stuName;
        this.score = score;
    }

    public int getStuId() {
        return stuId;
    }

    public void setStuId(int stuId) {
        this.stuId = stuId;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    @Override
    public int compareTo(Student o) {
        return stuId-o.stuId;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuId=" + stuId +
                ", stuName='" + stuName + '\'' +
                ", score=" + score +
                '}';
    }

    public static void main(String[] args) {
        Student []students=new Student[]{
                new Student(2,"张三",90),
                new Student(3,"王老五",100),
                new Student(1,"李四",87),
                new Student(4,"小明",99)
        };

        Arrays.sort(students);
        for (Student student:students
        ) {
            System.out.println(student.toString());
        }
    }
}

